<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>新增地址</title>
	<link rel="stylesheet" href="">
	<link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_1457937316_1758883.css">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/style1.css" rel="stylesheet">
    <link rel="stylesheet" href="">
    <link rel="stylesheet" type="text/css" href="css/dizist.css">
   <script src="js/jquery.min.js"></script>
   <script src="js/bootstrap.min.js"></script>
    <script src="js/vue.js"></script>
<script language="javascript" src="js/jquery.gcjs.js"></script>

<!--必要样式-->
<link rel="stylesheet" type="text/css" href="css/menu_elastic.css" />
<script src="js/snap.svg-min.js"></script>
<!--[if IE]>
    <script src="js/html5.js"></script>
    <![endif]-->
</head>
<body class="huibg">
<div class="menu-wrap">
    <nav class="menu">
      <div class="icon-list">
        <a href="index.html"><i class="iconfont icon-home"></i><span>首页</span></a>
        <a href="/weixin/queryIndex"><i class="iconfont icon-yonghux"></i><span>个人中心</span></a>
        <a href="ddcenter.html"><i class="iconfont icon-liebiao"></i><span>订单中心</span></a>
        <a href="dizhi.html"><i class="iconfont icon-dizhi"></i><span>地址信息</span></a>
      </div>
    </nav>
    <button class="close-button" id="close-button">Close Menu</button>
    <div class="morph-shape" id="morph-shape" data-morph-open="M-1,0h101c0,0,0-1,0,395c0,404,0,405,0,405H-1V0z">
      <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 100 800" preserveAspectRatio="none">
        <path d="M-1,0h101c0,0-97.833,153.603-97.833,396.167C2.167,627.579,100,800,100,800H-1V0z"/>
      </svg>
    </div>
  </div>
<nav class="navbar text-center">
   <button class="topleft" onclick ="javascript:history.go(-1);"><span class="iconfont icon-fanhui"></span></button>
  <a class="navbar-tit center-block">新增地址</a>
<!--  <button class="topnav" id="open-button"><span class="iconfont icon-1"></span></button>-->
</nav>
</div>

<div id="el">
<div class="usercenter">
  <div class="cdv">
    <input type="text" placeholder="请输入姓名" v-model="info.name" @blur="namebl"><span id="sname" v-text="sname"></span>
  </div>
  <div class="cdv">
    <input type="text" placeholder="请输入电话" v-model="info.tel" @blur="telbl" ><span id="stel" v-text="stel"></span>
  </div>
  <div class="cdv">
    <!-- sel-provance -->
    <select id="s_province" name="s_province" v-model="info.province" @change="addressbl"></select><br>
  </div>
  <div class="cdv">
    <select id="s_city" name="s_city" v-model="info.city" @change="addressbl"></select><br><!-- sel -->
  </div>
  <div class="cdv">
    <!-- sel-area -->
     <select id="s_county" name="s_county" v-model="info.county" @change="addressbl"></select><br>
  </div>
  <div class="cdv">
    <input type="text" placeholder="请输入详细地址,如XX小区X栋X号" v-model="info.content" @blur="addressbl"><span  v-text="saddress"></span>
  </div>
  <button type="button" class="btnlg" @click="insertDizhi">提交</button>
</div>
    <div style="height: 50px;"> </div>

    <div class="footnav" style="z-index: 999">
        <div class="col-xs-3 text-center"><a href="/weixin/shoppingMall"><i class="iconfont icon-shop"></i><p>商城</p></a></div>
        <div class="col-xs-3 text-center"><a href="details.html"><i class="iconfont icon-huodongfj"></i><p>关于我们</p></a></div>
        <div class="col-xs-3 text-center"><a href="/weixin/shoppingmall/my-order.html"><i class="iconfont icon-liebiao"></i><p>订单中心</p></a></div>
        <div class="col-xs-3 text-center"><a href="mendian.html"><i class="iconfont icon-dizhi"></i><p>附近门店</p></a></div>
    </div>
</div>
<script src="js/classie.js"></script>
<script src="js/main3.js"></script>
<script type="text/javascript" src="js/area.js"></script>
<script type="text/javascript">
    window.onload=function(){
        _init_area();
    }
  var vue=new Vue({
      el:"#el",
      data:{
        info:{
           name:"",
            tel:"",
            province:"省份",
            city:"地级市",
            county:"市、县级市",
            content:""
        },
          sname:"",
          stel:"",
          saddress:""
      },
      methods:{
            insertDizhi:function(){
                this.namebl();
                this.telbl();
                this.addressbl();
                if(this.sname.trim()=="" && this.stel.trim()=="" && this.saddress.trim()==""){
                    var add=this.info.province.trim()+this.info.city.trim()+this.info.county.trim()+this.info.content
                    var _this=this;
                $.ajax({
                    url: "/weixin/insertDizhi",
                    type:"get",
                    dataType:"json",
                    data:{"name":_this.info.name,
                    "tel":_this.info.tel,
                        "addr":add
                    },
                    success:function(data){
                       if(data.obj==null){
                           alert("请关注公众号后后再进行操作")
                           window.location.href="/weixin/queryIndex"
                       }else{
                           alert("新增成功")
                           window.location.href="dizhi.html"
                       }
                    }
                })
                }
          },
          namebl:function(){
                console.log(this.info.name)
              if(this.info.name==null ||this.info.name.trim()==""){
                  this.sname="姓名不能为空"
              }else{
                  this.sname="";
              }
          },
          telbl:function(){
              var uPattern=/^1[3|4|5|7|8]\d{9}$/;
              if(uPattern.test(this.info.tel)){
                  this.stel="";
              }else{
                  this.stel="请填写正确的号码";
              }
          },
          addressbl:function(){
                if (this.info.province=="省份" ||this.info.province.trim()=="" ||this.info.city.trim()=="地级市"  || this.info.city.trim()=="" || this.info.county=="市、县级市"  || this.info.county=="" ||this.info.content.trim()==""){
                    this.saddress="地址输入不规范";
                }else{
                    this.saddress="";
                }
          }
      }

  })
</script>

</body>
</html>